package com.refactor.demo;

/**
 * MovieTypeEnums
 *
 * @author mashiquan
 * @version 1.0
 * @description
 * @date 2023/12/25 23:53
 */
public enum MovieTypeEnums {

    REGULAR(0,"REGULAR"),
    NEW_RELEASE(1,"NEW_RELEASE"),
    CHILDREN(2,"CHILDREN");

    private int typeCode;
    private String typeTitle;

    public int getTypeCode() {
        return typeCode;
    }

    public void setTypeCode(int typeCode) {
        this.typeCode = typeCode;
    }

    public String getTypeTitle() {
        return typeTitle;
    }

    public void setTypeTitle(String typeTitle) {
        this.typeTitle = typeTitle;
    }

    MovieTypeEnums(int typeCode, String typeTitle) {
        this.typeCode = typeCode;
        this.typeTitle = typeTitle;
    }

    public static MovieTypeEnums getInstance(int code){
        for (MovieTypeEnums e: values()) {
            if(code ==e.getTypeCode()){
                return e;
            }
        }
        throw new IllegalArgumentException("未知的参数类型");
    }
}
